package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.HouseBean;
import com.sx.zongzhi.modle.CollectManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IFactHouseDetailView;

import java.util.Map;

/**实有房屋/出租房详情
 * Created by admin on 2017/12/13.
 */

public class FactHouseDetailPest {
    private IFactHouseDetailView iFactHouseDetailView;

    public FactHouseDetailPest(IFactHouseDetailView iFactHouseDetailView) {
        this.iFactHouseDetailView=iFactHouseDetailView;
    }
    //实有房屋/出租房详情
    public void getFactHouseDetail(Context context, String id){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("id", id);
        new CollectManager().getFactHouseDetail(map, new BaseCallBack<BaseResult<HouseBean>>() {
            @Override
            public void onSuccess(BaseResult<HouseBean> response) {
                iFactHouseDetailView.getFactHouseDetailSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iFactHouseDetailView.showError(message);
            }
        });
    }
    //删除 实有房屋/出租房详情
    public void deleteFactHouse(Context context, String id){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("id", id);
        new CollectManager().deleteFactHouse(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                iFactHouseDetailView.deleteFactHouseSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iFactHouseDetailView.showError(message);
            }
        });
    }

    /**
     * 楼宇管理的解绑楼宇
     * @param context
     * @param houseId 房屋的id
     */
    public void unbindBuilding(Context context, String houseId){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("houseId", houseId);
        new CollectManager().unbindBuilding(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                iFactHouseDetailView.deleteFactHouseSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                iFactHouseDetailView.showError(message);
            }
        });
    }
}
